 <form class="layui-form" action="" lay-filter="svrPv">
<div class="layuimini-main">
	<div class="layui-form layuimini-form">
		<div class="layui-form-item">
			<label class="layui-form-label required">名称</label>
			<div class="layui-input-block">
				<input type="text" name="name" lay-verify="required"
					lay-reqtext="不能为空,长度小于50个字" maxLength='50' placeholder="和工商登记名一致"
					value="" class="layui-input">
				<input type="hidden" name="type" /><!--  -->	
				<input type="hidden" name="status" /><!--  -->	
				<!--  <tip>请填写服务商名称。需要服务商</tip> -->
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">简称</label>
			<div class="layui-input-block">
				<input type="text" name="nameShort" lay-verify="required|snameIsUnique"
					maxLength='20' placeholder="简化名称,短小精干,易于记忆" value="" class="layui-input"> 
			</div>
		</div>
		<div class="layui-form-item" id="area-picker">
			<div class="layui-form-label required">区域</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="province" class="province-selector" data-value="西藏自治区"
					lay-filter="province-1">
					<option value="">请选择省</option>
				</select>
			</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="city" class="city-selector" data-value="拉萨市"
					lay-filter="city-1">
					<option value="">请选择市</option>
				</select>
			</div>
			<div class="layui-input-inline" style="width: 200px;">
				<select name="county" class="county-selector" data-value="城关区"
					lay-filter="county-1">
					<option value="">请选择区</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">地址</label>
			<div class="layui-input-block">
				<input type="text" name="addar" maxLength='50'
					placeholder="长度小于50个字" value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">联系电话</label>
			<div class="layui-input-block">
				<input type="phone" name="tel" maxLength='20'
					placeholder="座机号码(区号-座机号)" lay-verify="required|tel" 
					value="" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label required">管理员手机</label>
			<div class="layui-input-block">
				<input type="phone" name="town" maxLength='20'
					placeholder="11位手机号码"  lay-verify="required|phone|telIsUnique"
					value="" class="layui-input">
					<tip>请正确填写管理员手机。管理员登录时用,默认密码为[88888888]</tip>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit
					lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
</div>
</form>
<script>
    layui.use(['form', 'table','layer','layarea','common'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            layarea = layui.layarea,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.val("svrPv", window.svrInitData)
        form.render();
        //console.log(form);
       	//from.type=window.svrType

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

		layarea.render({
		        elem: '#area-picker',
		        // data: {
		        //     province: '广东省',
		        //     city: '深圳市',
		        //     county: '龙岗区',
		        // },
		        change: function (res) {
		            //选择结果
		            //console.log(res);
		        }
		    });
		    
 		//校验输入
		form.verify({
 				snameIsUnique: function (value) {
					if (!layui.common.isExist("/isp/unique/"+value))
				 		return "简称已被使用,请重新输入新的简称";
                },
 				telIsUnique: function (value) {
					if (!layui.common.isExist("/user/unique/"+value))
				 		return "手机号已被使用,请重新输入新的手机号";
                }
 		 })
         //监听提交
        form.on('submit(saveBtn)', function (data) {
        //return false;
        	$.ajax({
				url: "/isp",
				type: 'put',
				async: false,
				data : JSON.stringify(data.field),//要转换为字符格式
				dataType: 'json',
				contentType:"application/json",
				success: function(data) {
					window.data= data.obj;
					//console.log(data.obj);
					window.isSubmit=true;
					// 关闭弹出层
           			layer.close(index);
            		layer.close(parentIndex);
				}
			});
            return false;
        });

    });
</script>